#pragma once
#include <QJsonDocument>
#include "global.h"
#include "singleton.h"

class HttpMng : public QObject, public Singleton<HttpMng>, public std::enable_shared_from_this<HttpMng> {
    Q_OBJECT
    friend class Singleton;

public:
    ~HttpMng() override;

    void PostHttpReq(const QUrl &url, const QJsonObject &json, ReqId req_id, Modules mod);

private:
    HttpMng();

    QNetworkAccessManager _networkManager;
signals:
    void sig_http_finish(ReqId req_id, QString res, ErrorCodes err, Modules mod);

    void sig_reg_mod_finish(ReqId id, QString res, ErrorCodes err);

private slots:
    void slot_http_finish(ReqId id, const QString &res, ErrorCodes err, Modules mod);
};
